import type PageContent from '@/components/page-content/page-content.vue'
import { ref } from 'vue'

function usePageContent() {
  const pageContentRef = ref<InstanceType<typeof PageContent>>()

  const handleSearchClick = () => {
    pageContentRef.value?.fetchPageData('init')
  }

  const handleResetClick = () => {
    pageContentRef.value && (pageContentRef.value.pagination.currentPage = 1)
    pageContentRef.value?.fetchPageData('init')
  }

  const handleDeleteClick = (payload)=>{
    pageContentRef.value?.deleteDataById([payload.id])
  }
  
  const handleSwitchClick = (payload)=>{
    pageContentRef.value?.handleSwitchChange(payload)
  }



  return { pageContentRef, handleSearchClick, handleResetClick,handleDeleteClick ,handleSwitchClick}
}

export default usePageContent
